package com.yx.backstage.converter;

import cn.hutool.core.date.DateUtil;
import com.yx.backstage.model.Manager;
import com.yx.backstage.model.vo.ManagerVo;
import com.yx.backstage.util.TimeFormat;

import java.util.ArrayList;
import java.util.List;

/**
 * @author YangXiong
 */
public class ManagerConverter {
    public static List<ManagerVo> handlerPageResult(List<Manager> records) {
        List<ManagerVo> result = new ArrayList<>();
        records.forEach(record->{
            ManagerVo vo = getManagerVo(record);
            result.add(vo);
        });
        return result;
    }

    public static ManagerVo getManagerVo(Manager record) {
        ManagerVo vo = new ManagerVo();
        vo.setId(record.getId());
        String format = DateUtil.format(record.getModifyTime(), TimeFormat.TIME_FORMAT);
        vo.setModifyTime(format);
        String create = DateUtil.format(record.getCreateTime(), TimeFormat.TIME_FORMAT);
        vo.setCreateTime(create);
        vo.setEnable(record.getEnable());
        vo.setPassword(record.getPassword());
        vo.setHeadImgUrl(record.getHeadImgUrl());
        vo.setUserId(record.getUserId());
        vo.setUserName(record.getUserName());
        vo.setOperatorName(record.getOperatorName());
        return vo;
    }
}
